package cn.com.code.generator.base.vo;

import cn.com.do1.dsf.common.xss.SQLFilter;
import com.baomidou.mybatisplus.plugins.Page;
import org.apache.commons.lang.StringUtils;

/**
 * 分页VO
 *
 * @Author yangjun
 * @Date 2019/8/12
 **/
public class PageVO {

    private int pageInt = 1;

    private int limitInt = 10;

    private String page;

    private String limit;

    private String sidx;

    private String order;

    private Page pager;

    public Page getPager() {
        if (this.pager == null) {
            if (page != null) {
                this.pageInt = Integer.parseInt(page);
            }
            if (limit != null) {
                this.limitInt = Integer.parseInt(limit);
            }
            sidx = SQLFilter.sqlInject(sidx);
            order = SQLFilter.sqlInject(order);
            this.pager = new Page(this.pageInt, this.limitInt);
            if (StringUtils.isNotBlank(sidx) && StringUtils.isNotBlank(order)) {
                this.pager.setOrderByField(sidx);
                this.pager.setAsc("ASC".equalsIgnoreCase(order));
            }
        }
        return this.pager;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public String getLimit() {
        return limit;
    }

    public void setLimit(String limit) {
        this.limit = limit;
    }
}
